<template>
    <a-card :bordered="false">
        <div class="table-operator">
            <a-button shape="round" size="small" type="primary" icon="plus" @click="handleEdit({},'transportForm','新增')">添加</a-button>
        </div>

        <LTable
        ref="transportList"
        size="middle"
        rowKey="keyId"
        :formAttributes="formAttributes"
        :columns="columns"
        :initOrder="[{'field': 'createTime','val': 'desc'}]"
        axiosUrl="/KhyTransportController/page"
        :showPagination="true"
        :showQueryForm="true"
      >

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'transportForm','运输单详情')">详情</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete({keyId:record.keyId},'/KhyTransportController/del','transportList')">
                <a>删除</a>
            </a-popconfirm>
        </span>
        
    </LTable>
    <transportForm ref="transportForm" @close="refresh('transportList')" @ok="refresh('transportList')"></transportForm> 
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import request from '@/utils/request'
import transportForm from './transportForm'
import {SysMixin} from '@/mixins/SysMixin'
import defaultSettings from '@/config/defaultSettings'
export default {
    name:'transportList',
    components:{LTable,transportForm},
    mixins:[SysMixin],
    data(){
        return{
            initDictCodes:defaultSettings.数据字典.货运单状态下拉+','+defaultSettings.数据字典.车辆下拉+','+defaultSettings.数据字典.司机下拉,
            defaultSettings,
            formAttributes:[
                {field:'plateNo',label:'车牌号',component:'select',condition:'eq',dictCode:defaultSettings.数据字典.车辆下拉},
                {field:'driverNo',label:'司机',component:'select',condition:'eq',dictCode:defaultSettings.数据字典.司机下拉},
                {field:'createTime',label:'时间',component:'time',condition:'between'},
                
            ],
         
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                
                {
                    title: '车牌号',
                    dataIndex: 'plateNo',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.车辆下拉,text)
                        }
                    }
                },
                {
                    title: '司机',
                    dataIndex: 'driverNo',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.司机下拉,text)
                        }
                    }
                },
               {
                    title: '开始时间',
                    dataIndex: 'createTime',
               },
               {
                    title: '结束时间',
                    dataIndex: 'endTime',
               },
                {
                    title:'运单状态',
                    dataIndex:'transportState',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.货运单状态下拉,text)
                        }
                    }
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '120px',
                    scopedSlots: { customRender: 'action' }
                }
            ],
            
        }
    },
    created(){
       
    },
    methods:{
       
    }
}
</script>